Skip to content

Fix: DataGrid last column resize to view width#3417

Merged
mergify[bot] merged 8 commits intomainfrom
fix/datagrid-fill-last-row
May 10, 2026
Merged

Fix: DataGrid last column resize to view width#3417
mergify[bot] merged 8 commits intomainfrom
fix/datagrid-fill-last-row

Conversation

@BornToBeRoot
Copy link
Copy Markdown
Owner

Changes proposed in this pull request

Related issue(s)

Copilot AI review requested due to automatic review settings May 5, 2026 22:59
@github-actions github-actions Bot added this to the next-release milestone May 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses a WPF DataGrid layout quirk where star-sized (Width="*") columns initially render at their MinWidth when the grid starts empty, causing the last/main column to only fill remaining width after a window resize (Fixes #3416).

Changes:

  • Adds a one-shot LoadingRow handler to force star column width recomputation after the first row is realized.
  • Updates the DNS lookup results grid so the Result column uses Width="*" and enables text wrapping.
  • Slightly increases the query type ComboBox width (80 → 100).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Source/NETworkManager/Views/DNSLookupView.xaml Makes the results grid nameable and hooks LoadingRow; sets the last column to Width="*" with wrapping so it fills remaining width on first paint.
Source/NETworkManager/Views/DNSLookupView.xaml.cs Implements a one-shot LoadingRow handler that re-triggers star column measurement via dispatcher after the first row loads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BornToBeRoot BornToBeRoot requested a review from Copilot May 10, 2026 21:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Comment on lines +35 to +54
// Force star-sized DataGrid columns to recompute on first row load. Without this, an
// initially empty DataGrid sizes star columns to MinWidth because the inner ScrollViewer
// measures with infinite width; only a window resize triggers a correct re-measure.
private void DataGridResults_LoadingRow(object sender, DataGridRowEventArgs e)
{
DataGridResults.LoadingRow -= DataGridResults_LoadingRow;

Dispatcher.BeginInvoke(new Action(() =>
{
foreach (var column in DataGridResults.Columns)
{
if (!column.Width.IsStar)
continue;

var width = column.Width;
column.Width = 0;
column.Width = width;
}
}), DispatcherPriority.ContextIdle);
}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 353e69a. Extracted the duplicated one-shot handler into a DataGridHelper.RefreshStarColumnsOnFirstRow attached property in NETworkManager.Utilities.WPF/DataGridHelper.cs. All 14 XAML views now use wpfHelper:DataGridHelper.RefreshStarColumnsOnFirstRow="True" (using the existing namespace alias in each file) instead of event handler bindings, and the duplicated handler methods have been removed from all 14 code-behind files.

Comment thread Source/NETworkManager/Views/PortScannerView.xaml
Comment thread Source/NETworkManager/Views/PortScannerView.xaml Outdated
Comment thread Source/NETworkManager/Views/DNSLookupView.xaml
Comment thread Source/NETworkManager/Views/NeighborTableView.xaml
BornToBeRoot and others added 2 commits May 10, 2026 23:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ched property

Agent-Logs-Url: https://github.com/BornToBeRoot/NETworkManager/sessions/090031d0-133d-4e38-becd-526f4b8dd846

Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
@mergify mergify Bot merged commit 3f5f37f into main May 10, 2026
5 checks passed
@mergify mergify Bot deleted the fix/datagrid-fill-last-row branch May 10, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Result DataGrids: last column does not fill remaining width until window resize

3 participants